---
title: "SQL-001: Insert a task"
summary: Persist a new task row via the pk82036_task.task_insert stored procedure.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
---

# SQL-001 Insert a task

Inserts a new `TASK` row by calling the Oracle stored procedure `pk82036_task.task_insert` with 21 input parameters and a `RowsAffected` return value.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-001 |
| **Operation type** | Create |
| **Execution method** | Stored procedure |
| **Database** | Oracle |
| **Schema** | `[unqualified]`** |
| **Command type** | StoredProcedure |
| **Business object** | `clsTask` |
| **Criteria property** | `InsertSQL` |
| **Lifecycle method** | `BeforeInsert` / `AfterInsert` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:CreateUser` | Input | String | 30 | Creating user ID (defaults to `IDataPortalInfo.UserID`, [BR-014](../business-rules.md#br-014-creating-user-defaults-to-the-data-portal-user-identity)) |
| `:UpdateUser` | Input | `clsSmartString` | 30 | Last-update user ID (mirrors `CreateUser` on insert) |
| `:DeleteFlag` | Input | String | 1 | Completion/soft-delete flag; `N` on new tasks ([BR-015](../business-rules.md#br-015-new-tasks-start-not-completed-and-without-a-notepad-entry)) |
| `:NotepadFlag` | Input | String | 1 | Notepad-entry flag; `N` on new tasks ([BR-015](../business-rules.md#br-015-new-tasks-start-not-completed-and-without-a-notepad-entry)) |
| `:TaskUser` | Input | String | 30 | Assigned MailID (trimmed/upper-cased, [BR-016](../business-rules.md#br-016-mailids-are-stored-and-compared-trimmed-and-upper-cased)) → `TASK.TASK_USER` |
| `:TaskActionCode` | Input | String | 5 | Action code from the concrete task's `ActionCode` |
| `:TaskCategoryCode` | Input | String | 30 | Task category code (column is 5-char in the code table; parameter declared 30)* |
| `:TaskDate` | Input | `clsSmartDate` | — | Task due date (normalized to a working day, [BR-009](../business-rules.md#br-009-a-non-working-day-due-date-is-moved-to-a-working-day)) |
| `:TaskPriorityCode` | Input | String | 5 | Task priority code |
| `:TaskSourceCode` | Input | String | 5 | Source system code (insert only — immutable afterwards) |
| `:TaskText` | Input | String | 4000 | Task narrative text |
| `:PolicyNum` | Input | `clsSmartDecimal` | — | Optional policy number (nullable) |
| `:ClaimID` | Input | `clsSmartDecimal` | — | Optional claim ID (nullable) |
| `:ImageSeqNum` | Input | `clsSmartDecimal` | — | Optional imaging document sequence number (nullable) |
| `:TaskSecurity` | Input | String | 30 | Security classification string (stored, never evaluated in this library) |
| `:ContextDate` | Input | `clsSmartDate` | — | Context date value |
| `:ContextNum` | Input | `clsSmartDecimal` | — | Context numeric value |
| `:ContextCode` | Input | `clsSmartString` | 5 | Context code |
| `:ContextCategory` | Input | `clsSmartString` | 100 | Context category |
| `:ContextKey` | Input | `clsSmartString` | 100 | Context key |
| `:ContextText` | Input | `clsSmartString` | 4000 | Context text value |
| `:RowsAffected` | ReturnValue | Integer | N/A | Rows written; checked by `AfterInsert` ([BR-010](../business-rules.md#br-010-task-insert-must-affect-exactly-one-row)) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK](../database-tables.md#task) | INSERT | All 25 `TASK` columns (see parameter list) |

## Sample SQL

```sql
-- CommandType.StoredProcedure, RequestType = NonQuery, DataRequest.ID = "INSERT"
CALL pk82036_task.task_insert(
  :CreateUser,
  :UpdateUser,
  :DeleteFlag,
  :NotepadFlag,
  :TaskUser,
  :TaskActionCode,
  :TaskCategoryCode,
  :TaskDate,
  :TaskPriorityCode,
  :TaskSourceCode,
  :TaskText,
  :PolicyNum,
  :ClaimID,
  :ImageSeqNum,
  :TaskSecurity,
  :ContextDate,
  :ContextNum,
  :ContextCode,
  :ContextCategory,
  :ContextKey,
  :ContextText,
  :RowsAffected)
```

The procedure body resides in the Oracle database and could not be retrieved in this environment. Parameter order above reflects the `AddParm` call order in `clsTask.BeforeInsert`; the actual PL/SQL formal parameter list is unverified.**

## Operations and processes
- [Create/insert a task](../operations/create-insert-task.md)
- [Save a task collection](../operations/save-task-collection.md)

## Business rules
- [BR-001: A task must have a Task Category Code](../business-rules.md#br-001-a-task-must-have-a-task-category-code)
- [BR-002: A task must have a Source System Code](../business-rules.md#br-002-a-task-must-have-a-source-system-code)
- [BR-003: A task must have a Priority Code](../business-rules.md#br-003-a-task-must-have-a-priority-code)
- [BR-004: A task must be assigned to a MailID](../business-rules.md#br-004-a-task-must-be-assigned-to-a-mailid)
- [BR-010: Task insert must affect exactly one row](../business-rules.md#br-010-task-insert-must-affect-exactly-one-row)
- [BR-014: Creating user defaults to the data-portal user identity](../business-rules.md#br-014-creating-user-defaults-to-the-data-portal-user-identity)
- [BR-015: New tasks start not-completed and without a notepad entry](../business-rules.md#br-015-new-tasks-start-not-completed-and-without-a-notepad-entry)
- [BR-016: MailIDs are stored and compared trimmed and upper-cased](../business-rules.md#br-016-mailids-are-stored-and-compared-trimmed-and-upper-cased)
- [BR-027: Task text is never null](../business-rules.md#br-027-task-text-is-never-null)

## Sources
- SAIF.Business.Tasks/clsTask.vb
